﻿using rehot.core;
using System;

namespace rehot
{
    public static class HotEvent
    {
        public static object[] Read(params IHotEvent[] _events)
        {
            var _ps = new object[_events.Length];
            for (int i = 0; i < _events.Length; i++) _ps[i] = _events[i].Get();
            return _ps;
        }

        public static HotEvent<TEvent> Put<TEvent>(TEvent function) where TEvent : Delegate
        {
            var handler = new HotEvent<TEvent>();

            handler.handler = function;
            return handler;
        }
    }

    public class HotEvent<TEvent> : IHotEvent where TEvent : Delegate
    {
        internal TEvent handler { get; set; }

        public object Get()
        {
            return handler;
        }
    }
}
